package gas.model;


import java.util.*;
/***
 * Data Structure to hold Gas Stations.
 *
 * @author Alfred Tarng
 *
 */

public class GasStationBase {
    private ArrayList<GasStation> gasTable = new ArrayList<GasStation>();
    private static int stationCounter = 0;
    
    /*****************************
     * Constructor
     * pre: none
     * post: none
     * return: none
     */
    public GasStationBase(){}
    
    /*****************************
     * newStation
     * pre: stationName - String
     *      currentPrice - int
     *      LE - LocationsEnum
     * post: stationCounter is incremented
     *       gasTable contains the new potentialStation, with valid members
     * return: always returns true
     */
    public boolean newStation( String stationName, int currentPrice, LocationsEnum LE ){
      GasStation potentialStation = new GasStation();
      //IA: potentialStation now points to something
      
      potentialStation.setStationName(stationName);
      potentialStation.setStationID(stationCounter++);
      potentialStation.setCurrentPrice(currentPrice);
      potentialStation.setLocation(LE);
      //IA: potentialStation now has valid members
      
      gasTable.add(potentialStation);
      //IA: potentialStation is now in gasTable
      return true;
    }
    
    /*****************************
     * getGasTable
     * pre: none
     * post: none
     * return: gasTable
     */
    public ArrayList<GasStation> getGasTable(){
        return this.gasTable;
    }

    public static boolean selfTest(){
      System.out.println("Running GasBase Tests");
      boolean passAll = true;
      GasStationBase testGasBase = new GasStationBase();
      testGasBase.newStation("76", 460, LocationsEnum.NOWHERE);
      passAll = passAll & ( testGasBase.getGasTable().size() == 1 ) ;
      
      return passAll;
    }
    
}